<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Action Semantics</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Action Semantics' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">if</a></li><li><a href="index.html#4">Chapter 4: Actions</a></li><li><b>Action Semantics</b></li></ul></div>
<p class="purpose">Constraints on how actions may be used in the model world.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>For example, the "inserting it in" action requires two objects to act on,
not, for example, a single number. Action semantics are to an action name
as a type signature is to a function.
</p>

<p class="commentary">An action involves "parameters", that is, nouns which are involved in it:
there would be 2 for "inserting it in", which is the maximum allowed. By
long-standing tradition, the first parameter is called the "noun" and the
second is called the "second".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">action_semantics</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">out_of_world</span><span class="plain-syntax">; </span><span class="comment-syntax"> action is declared as out of world?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">requires_light</span><span class="plain-syntax">; </span><span class="comment-syntax"> does this action require light to be carried out?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">min_parameters</span><span class="plain-syntax">, </span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax">; </span><span class="comment-syntax"> in the range 0 to 2</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">noun_access</span><span class="plain-syntax">; </span><span class="comment-syntax"> one of the possibilities below</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">second_access</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">noun_kind</span><span class="plain-syntax">; </span><span class="comment-syntax"> if there is at least 1 parameter</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">second_kind</span><span class="plain-syntax">; </span><span class="comment-syntax"> if there are 2 parameters</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">action_semantics</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure action_semantics is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>A newly created action, by default, has this:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">action_semantics</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::default</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::default</span></span>:<br/>Actions - <a href="4-act.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">action_semantics</span><span class="plain-syntax"> </span><span class="identifier-syntax">sem</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">out_of_world</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">requires_light</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">min_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">noun_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_object</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">noun_access</span><span class="plain-syntax"> = </span><span class="identifier-syntax">UNRESTRICTED_ACCESS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">second_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_object</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">sem</span><span class="plain-syntax">.</span><span class="element-syntax">second_access</span><span class="plain-syntax"> = </span><span class="identifier-syntax">UNRESTRICTED_ACCESS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">sem</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>The code in this section looks as if more possibilities might exist, but in
fact Inform creates actions with only four configurations of min and max
parameters: \((0, 0), (0, 1), (1, 1), (2, 2)\). Actions with an optional noun,
the \((0, 1)\) case, are a residue of the days of Inform 6, which allowed for
example "listening" and "listening to the frog" as the same action. Today the
preferred way to do that is to use activities for selecting missing parameters.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::give_action_an_optional_noun</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::give_action_an_optional_noun</span></span>:<br/>Actions Plugin - <a href="4-ap.html#SP10_5">&#167;10.5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">acc</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">min_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_access</span><span class="plain-syntax"> = </span><span class="identifier-syntax">acc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::give_action_one_noun</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::give_action_one_noun</span></span>:<br/>Actions Plugin - <a href="4-ap.html#SP10_6">&#167;10.6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">acc</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">min_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_access</span><span class="plain-syntax"> = </span><span class="identifier-syntax">acc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::give_action_two_nouns</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::give_action_two_nouns</span></span>:<br/>Actions Plugin - <a href="4-ap.html#SP10_7">&#167;10.7</a>, <a href="4-ap.html#SP10_8">&#167;10.8</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">acc1</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K1</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">acc2</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">min_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_access</span><span class="plain-syntax"> = </span><span class="identifier-syntax">acc1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">second_access</span><span class="plain-syntax"> = </span><span class="identifier-syntax">acc2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">second_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">K1</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">K2</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_ActionBothValues</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="string-syntax">"this action definition asks to have a single action apply "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"to two different things which are not objects"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"and unfortunately a fundamental restriction is that an "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"action can apply to two objects, or one object and one "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"value, but not to two values. Sorry about that."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::make_action_out_of_world</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::make_action_out_of_world</span></span>:<br/>Actions Plugin - <a href="4-ap.html#SP10_1">&#167;10.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">out_of_world</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::make_action_require_light</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::make_action_require_light</span></span>:<br/>Actions Plugin - <a href="4-ap.html#SP10_4">&#167;10.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">requires_light</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>It clarifies code elsewhere to give these conditions names as functions:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::can_have_noun</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::can_have_noun</span></span>:<br/><a href="4-as.html#SP6">&#167;6</a><br/>Action Name Names - <a href="4-ann.html#SP13">&#167;13</a><br/>Action Name Lists - <a href="4-anl.html#SP30_6">&#167;30.6</a>, <a href="4-anl.html#SP34_1_3">&#167;34.1.3</a><br/>Parse Clauses - <a href="4-pc.html#SP1_3">&#167;1.3</a><br/>Explicit Actions - <a href="4-ea.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::can_have_second</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::can_have_second</span></span>:<br/><a href="4-as.html#SP6">&#167;6</a><br/>Parse Clauses - <a href="4-pc.html#SP1_3">&#167;1.3</a><br/>Explicit Actions - <a href="4-ea.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::must_have_noun</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::must_have_noun</span></span>:<br/>Explicit Actions - <a href="4-ea.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">min_parameters</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::must_have_second</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::must_have_second</span></span>:<br/>Explicit Actions - <a href="4-ea.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">min_parameters</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::max_parameters</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::requires_light</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">requires_light</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::is_out_of_world</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::is_out_of_world</span></span>:<br/>Actions - <a href="4-act.html#SP6">&#167;6</a><br/>Parse Clauses - <a href="4-pc.html#SP1_3">&#167;1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">out_of_world</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::noun_access</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::noun_access</span></span>:<br/><a href="4-as.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_access</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::second_access</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::second_access</span></span>:<br/><a href="4-as.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">second_access</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionSemantics::kind_of_noun</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::kind_of_noun</span></span>:<br/><a href="4-as.html#SP5">&#167;5</a>, <a href="4-as.html#SP6">&#167;6</a><br/>Parse Clauses - <a href="4-pc.html#SP1_1_2">&#167;1.1.2</a>, <a href="4-pc.html#SP1_3">&#167;1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">noun_kind</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">ActionSemantics::kind_of_second</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::kind_of_second</span></span>:<br/><a href="4-as.html#SP5">&#167;5</a><br/>Parse Clauses - <a href="4-pc.html#SP1_1_1">&#167;1.1.1</a>, <a href="4-pc.html#SP1_1_2">&#167;1.1.2</a>, <a href="4-pc.html#SP1_3">&#167;1.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="element-syntax">second_kind</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>And this simple function amounts to a typechecker for a use of an action.
But note that it checks for too many nouns, but not for too few; so it can be
used to verify vaguely described actions in which no noun is given.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::check_valid_application</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">ActionSemantics::check_valid_application</span></span>:<br/>Command Grammar Lines - <a href="5-cgl.html#SP16_2">&#167;16.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">nouns_supplied</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> **</span><span class="identifier-syntax">noun_kinds</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">possible</span><span class="plain-syntax"> = </span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">semantics</span><span class="plain-syntax">.</span><span class="identifier-syntax">max_parameters</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">nouns_supplied</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">possible</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">possible</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"this action applies to nothing, but you have provided "</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"material in square brackets which expands to something"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"this action applies to just one thing, but you have "</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"put more than one thing in square brackets"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">default:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"this action applies to two things, the maximum possible, "</span>
<span class="plain-syntax">                    </span><span class="string-syntax">"but you have put more than two in square brackets"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="4-as.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Issue an action usage problem</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">nouns_supplied</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::noun_access</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">UNRESTRICTED_ACCESS:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">supplied_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">noun_kinds</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">desired_kind</span><span class="plain-syntax"> = </span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::kind_of_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::compatible</span><span class="plain-syntax">(</span><span class="identifier-syntax">supplied_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">desired_kind</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    != </span><span class="identifier-syntax">ALWAYS_MATCH</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"the thing you suggest this action should act on "</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"has the wrong kind of value"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="4-as.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Issue an action usage problem</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">REQUIRES_ACCESS:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">REQUIRES_POSSESSION:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">DOESNT_REQUIRE_ACCESS:</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">noun_kinds</span><span class="plain-syntax">[0]) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"the thing you suggest this action should act on "</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"is not an object at all"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="4-as.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Issue an action usage problem</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">nouns_supplied</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::second_access</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">UNRESTRICTED_ACCESS:</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">supplied_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">noun_kinds</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">desired_kind</span><span class="plain-syntax"> = </span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::kind_of_second</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::compatible</span><span class="plain-syntax">(</span><span class="identifier-syntax">supplied_kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">desired_kind</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    != </span><span class="identifier-syntax">ALWAYS_MATCH</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"the second thing you suggest this action should act on "</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"has the wrong kind of value"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="4-as.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Issue an action usage problem</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">REQUIRES_ACCESS:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">REQUIRES_POSSESSION:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">DOESNT_REQUIRE_ACCESS:</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">noun_kinds</span><span class="plain-syntax">[1]) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">failed_on</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"the second thing you suggest this action should act on "</span>
<span class="plain-syntax">                        </span><span class="string-syntax">"is not an object at all"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="4-as.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Issue an action usage problem</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue an action usage problem</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax">.</span><span class="identifier-syntax">designers_specification</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_text</span><span class="plain-syntax">(2, </span><span class="string-syntax">"&lt;none given&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(2,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax">.</span><span class="identifier-syntax">designers_specification</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(3, </span><a href="4-ann.html#SP5" class="function-link"><span class="function-syntax">ActionNameNames::tensed</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">, </span><span class="identifier-syntax">IS_TENSE</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_text</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">failed_on</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_GrammarMismatchesAction</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">"The grammar you give in %1 is not compatible "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"with the %3 action (defined as '%2') - %4."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="4-as.html#SP5">&#167;5</a> (five times).</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>A stricter check is performed when we might want to compile an action in the
past tense; only very simple actions &mdash; those with no parameter, or a single
parameter which is a thing &mdash; can be tested this way, for reasons which become
clear from the implementation in <a href="../runtime-module/5-act.html" class="internal">Actions (in runtime)</a>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">ActionSemantics::can_be_compiled_in_past_tense</span><span class="plain-syntax">(</span><span class="reserved-syntax">action_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">an</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::can_have_second</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::can_have_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><a href="4-as.html#SP4" class="function-link"><span class="function-syntax">ActionSemantics::kind_of_noun</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">an</span><span class="plain-syntax">)) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="4-act.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-im.html">1</a></li><li class="progresschapter"><a href="2-bd.html">2</a></li><li class="progresschapter"><a href="3-sm.html">3</a></li><li class="progresscurrentchapter">4</li><li class="progresssection"><a href="4-ap.html">ap</a></li><li class="progresssection"><a href="4-anaa.html">anaa</a></li><li class="progresssection"><a href="4-ak.html">ak</a></li><li class="progresssection"><a href="4-ac.html">ac</a></li><li class="progresssection"><a href="4-act.html">act</a></li><li class="progresscurrent">as</li><li class="progresssection"><a href="4-av.html">av</a></li><li class="progresssection"><a href="4-ann.html">ann</a></li><li class="progresssection"><a href="4-ap2.html">ap2</a></li><li class="progresssection"><a href="4-anl.html">anl</a></li><li class="progresssection"><a href="4-apc.html">apc</a></li><li class="progresssection"><a href="4-pap.html">pap</a></li><li class="progresssection"><a href="4-pc.html">pc</a></li><li class="progresssection"><a href="4-ea.html">ea</a></li><li class="progresssection"><a href="4-nap.html">nap</a></li><li class="progresssection"><a href="4-gng.html">gng</a></li><li class="progresssection"><a href="4-rpoa.html">rpoa</a></li><li class="progresschapter"><a href="5-pp.html">5</a></li><li class="progresschapter"><a href="6-dlg.html">6</a></li><li class="progressnext"><a href="4-av.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

